package com.dekaru.math.dm;

import java.util.*;
import com.dekaru.math.type.*;

public class DMalu {

	private Hashtable<String, Object> hsh;
	
	// ==================
	// CLASS CONSTRUCTORS
	// ==================
	
	public DMalu() {
		this.hsh = new Hashtable<String, Object>();
	}
	
	// =====================
	// ACTUAL IMPLEMENTATION
	// =====================
	
	public void put(String name, Object obj) {
		
		this.hsh.put(name, obj);
	}
	
	// =======================
	// ARITHMETICAL OPERATIONS
	// =======================
	
	public String sum(String n1, String n2) {
		
		Object d1 = this.hsh.get(n1);
		Object d2 = this.hsh.get(n2);
		
		if (d1 instanceof Matrix) {
			Matrix m1 = (Matrix) d1;
			Matrix m2 = (Matrix) d2;
			Matrix m3 = m1.suma(m2); 
			this.hsh.put(n1+n2, m3);
			return m3.toString();
		}
		
		return "ERROR: unknown type";
	}
}
